﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QS.Drawables;
using DPSF;
using GameStateManagement;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;
using QS.Logic.Objects;
using QS.Game.Logic.Objects;

namespace QS.Game.Renderer
{
    class QLaserBulletRenderer: QAbstractRenderer
    {
        private Model model;

        public override void Draw(GraphicsDevice device, QCamera camera, SpriteBatch spriteBatch, IDrawableObject drawableObject)
        {
            QPhysicsObject Object = (QPhysicsObject)drawableObject;
            Matrix[] transforms = new Matrix[model.Bones.Count];

            foreach (ModelMesh mesh in model.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    effect.EnableDefaultLighting();
                    effect.View = camera.ViewMatrix;
                    effect.World = Matrix.CreateScale(5,100,5) * Matrix.CreateRotationY(MathHelper.ToRadians(180f)) * Matrix.CreateRotationX(MathHelper.ToRadians(90f)) * Matrix.CreateScale(0.005f) * Object.Orientation * Matrix.CreateTranslation(Object.Position);
                    effect.Projection = camera.ProjectionMatrix;
                }
                mesh.Draw();
            }
        }

        public override void LoadContent(GraphicsDevice graphicsDevice, ContentManager contentManager)
        {
            model = contentManager.Load<Model>("sphere");
        }
    }
}
